package com.start.captcha.web;

import com.start.common.api.Result;
import com.start.security.annotations.IgnoreAuth;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@IgnoreAuth
@RestController
@Tag(name = "验证码工具")
@RequestMapping("start/captcha")
public class StartCaptchaController {
    @Autowired
    private StartCaptchaService captchaService;

   @Operation(summary = "生成验证码")
    @GetMapping("/createCaptcha/{prefix}")
    public Result<?> createCaptcha(@PathVariable("prefix") String prefix) {
        return Result.ok(captchaService.createCaptcha(prefix));
    }

   @Operation(summary = "比对验证码")
    @GetMapping("/verification/{prefix}")
    public Result<?> verification(@PathVariable("prefix") String prefix, String captchaCode, String userInputCode) {
        return Result.ok(captchaService.verification(prefix, captchaCode, userInputCode));
    }
}
